/* For detailed instructions, see README file */


OPTIONS SOURCE MACROGEN SYMBOLGEN MPRINT SORTSIZE=MAX COMPRESS=YES ;




/*=========================================*/
/*Select path where files are saved - Please see README for more details*/
libname OP "INSERT PATH";
/*Select path to save logs - Please see README for more details*/
%let LOG_PATH= INSERT PATH\Table8.log;
options dlcreatedir; 
%PUT &LOG_PATH;
/*=========================================*/




proc printto log="&LOG_PATH" new;
run;



ODS GRAPHICS OFF;
ODS NORESULTS;
ODS SELECT NONE;
FOOTNOTE " ";
ODS TITLE " ";
/*=========================================*/
/*=========================================*/

DATA REG_DATA;
set OP.OPRA_Pseudo;

/*Table 8 quoted spread is scaled to dollars - see table caption*/

QUOTEDSPREAD_D= QUOTEDSPREAD_C/100;


CHARDATE = put(date,date9.);


KEEP

QUOTEDSPREAD_D
PFOF_IND
ARBITRAGE
DMMP_IND
Abs_Delta
STOCK_QS
INV_STOCK_MIDPOINT
QUOTEDSPREAD_C
GAMMA
VEGA
BUY_IND
INV_OPTION_MIDPOINT
CALL_IND
LOG_DAYS_EXP
LOG_S_VOL
TICK_CHANGE_IND
LOG_MCAP
UNIQUE_ID
DATE
SENDER
AUCTION_IND
DMM_IDENTITY
DATE
EQ
PImp_C
S_VOL
AUCTION_IND
QS_OPTIONSCALED
ES_OPTIONSCALED
EFFECTIVESPREAD_C
CHARDATE
SYMBOL_ONLY

;

RUN;




PROC SQL;
	CREATE TABLE REG_DATA_D1
	AS SELECT

	CHARDATE, SYMBOL_ONLY,

	PFOF_IND - 				MEAN(PFOF_IND) AS PFOF_IND,
	AUCTION_IND - 			MEAN(AUCTION_IND) AS AUCTION_IND,
	DMMP_IND - 				MEAN(DMMP_IND) AS DMMP_IND,
	ARBITRAGE - 			MEAN(ARBITRAGE) AS ARBITRAGE,
	Abs_Delta - 			MEAN(Abs_Delta) AS Abs_Delta,
	INV_STOCK_MIDPOINT - 	MEAN(INV_STOCK_MIDPOINT) AS INV_STOCK_MIDPOINT,
	GAMMA - 				MEAN(GAMMA) AS GAMMA,
	VEGA  - 				MEAN(VEGA) AS VEGA,
	INV_OPTION_MIDPOINT - 	MEAN(INV_OPTION_MIDPOINT) as INV_OPTION_MIDPOINT,
	CALL_IND - 				MEAN(CALL_IND) AS CALL_IND,
	LOG_DAYS_EXP - 			MEAN(LOG_DAYS_EXP) AS LOG_DAYS_EXP,
	LOG_S_VOL - 			MEAN(LOG_S_VOL) AS LOG_S_VOL,
	TICK_CHANGE_IND - 		MEAN(TICK_CHANGE_IND) AS TICK_CHANGE_IND,
	LOG_MCAP - 				MEAN(LOG_MCAP) AS LOG_MCAP,
	PIMP_C - 				MEAN(PIMP_C) AS PIMP_C,
	EQ - 					MEAN(EQ) AS EQ,
	QUOTEDSPREAD_D  -	 	MEAN(QUOTEDSPREAD_D) AS QUOTEDSPREAD_D ,
	EFFECTIVESPREAD_C  -	MEAN(EFFECTIVESPREAD_C) AS EFFECTIVESPREAD_C ,
	STOCK_QS - 				MEAN(STOCK_QS) AS STOCK_QS,
	BUY_IND  - 				MEAN(BUY_IND) AS BUY_IND

	FROM REG_DATA
	GROUP BY SYMBOL_ONLY;
QUIT;



PROC SQL;
	CREATE TABLE REG_DATA_D2
	AS SELECT

	CHARDATE, SYMBOL_ONLY,

	PFOF_IND - 				MEAN(PFOF_IND) AS PFOF_IND,
	AUCTION_IND - 			MEAN(AUCTION_IND) AS AUCTION_IND,
	DMMP_IND - 				MEAN(DMMP_IND) AS DMMP_IND,
	ARBITRAGE - 			MEAN(ARBITRAGE) AS ARBITRAGE,
	Abs_Delta - 			MEAN(Abs_Delta) AS Abs_Delta,
	INV_STOCK_MIDPOINT - 	MEAN(INV_STOCK_MIDPOINT) AS INV_STOCK_MIDPOINT,
	GAMMA - 				MEAN(GAMMA) AS GAMMA,
	VEGA  - 				MEAN(VEGA) AS VEGA,
	INV_OPTION_MIDPOINT - 	MEAN(INV_OPTION_MIDPOINT) as INV_OPTION_MIDPOINT,
	CALL_IND - 				MEAN(CALL_IND) AS CALL_IND,
	LOG_DAYS_EXP - 			MEAN(LOG_DAYS_EXP) AS LOG_DAYS_EXP,
	LOG_S_VOL - 			MEAN(LOG_S_VOL) AS LOG_S_VOL,
	TICK_CHANGE_IND - 		MEAN(TICK_CHANGE_IND) AS TICK_CHANGE_IND,
	LOG_MCAP - 				MEAN(LOG_MCAP) AS LOG_MCAP,
	PIMP_C - 				MEAN(PIMP_C) AS PIMP_C,
	EQ - 					MEAN(EQ) AS EQ,
	QUOTEDSPREAD_D  -	 	MEAN(QUOTEDSPREAD_D) AS QUOTEDSPREAD_D ,
	EFFECTIVESPREAD_C  -	MEAN(EFFECTIVESPREAD_C) AS EFFECTIVESPREAD_C ,
	STOCK_QS - 				MEAN(STOCK_QS) AS STOCK_QS,
	BUY_IND  - 				MEAN(BUY_IND) AS BUY_IND



	FROM REG_DATA_D1
	GROUP BY CHARDATE;
QUIT;








PROC SORT DATA=REG_DATA; BY SYMBOL_ONLY;RUN;
ODS OUTPUT ParameterEstimates = ParameterEstimates_clus (keep=parameter StdErr probt);
proc surveyreg data=REG_DATA_D2;
cluster SYMBOL_ONLY CHARDATE ;
 
model 
	AUCTION_IND=

	PFOF_IND
	ARBITRAGE
	QUOTEDSPREAD_D
	DMMP_IND
	Abs_Delta
	INV_STOCK_MIDPOINT
	STOCK_QS
	GAMMA
	VEGA
	BUY_IND
	TICK_CHANGE_IND
	INV_OPTION_MIDPOINT
	CALL_IND
	LOG_DAYS_EXP
	LOG_S_VOL
	TICK_CHANGE_IND
	LOG_MCAP



/NOINT
;


quit;
ODS HTML;





data ParameterEstimates_s_clus(keep=parameter value Type);
	set ParameterEstimates_clus;
	Type ="S";
	rename StdErr = Value;
	 IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	  	parameter = UPCASE(parameter);


run;

data ParameterEstimates_p_clus(keep=parameter probt);
	set ParameterEstimates_clus;
    IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	  parameter = UPCASE(parameter);

run;




PROC SORT DATA=REG_DATA; BY SYMBOL_ONLY;RUN;
ODS OUTPUT ParameterEstimates = ParameterEstimates;
ODS OUTPUT FitStatistics = FitStatistics;
ODS OUTPUT NObs = NObs;
proc glm namelen=64  data=REG_DATA;
CLASS CHARDATE;
ABSORB SYMBOL_ONLY;
model 

	AUCTION_IND=

	PFOF_IND
	ARBITRAGE
	QUOTEDSPREAD_D
	DMMP_IND
	Abs_Delta
	INV_STOCK_MIDPOINT
	STOCK_QS
	GAMMA
	VEGA
	BUY_IND
	TICK_CHANGE_IND
	INV_OPTION_MIDPOINT
	CALL_IND
	LOG_DAYS_EXP
	LOG_S_VOL
	TICK_CHANGE_IND
	LOG_MCAP


	CHARDATE 

/solution noint; 
run;
quit;




data FitStatistics (keep=parameter value Type);
	set FitStatistics;
	
	rename  RSquare=value;
	parameter = "Rsq";
	type ="E";
    IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;

run;





data ParameterEstimates_e (keep=parameter value Type);
	set ParameterEstimates;
	rename Estimate=value;
	Type="E";
	IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	 parameter = UPCASE(parameter);

run;





data nobs(keep=value type parameter);
	set nobs;
	type = "E";
	if label1 = "Number of Observations Read";
	parameter = "NObs";
	rename NObsRead = value;

run;



data Regression_3;
	set ParameterEstimates_e parameterEstimates_s_clus FITSTATISTICS nobs;

		if parameter="PFOF_IND" 			then n=2;
		if parameter="ARBITRAGE" 			then n=2.1;
		if parameter="QUOTEDSPREAD_D" 		then n=2.2;
		if parameter="DMMP_IND" 			then n=4;
		if parameter ="ABS_DELTA" 			then n=5;	
		if parameter="GAMMA" 				then n=6;
		if parameter ="VEGA" 				then n=7;
		if parameter="UNDERLYING_VOL" 		then n=8;
		if parameter = "STOCK_QS" 			then n=9;
		if parameter ="INV_OPTION_MIDPOINT" then n=10;
		if parameter ="INV_STOCK_MIDPOINT" 	then n=11;
		if parameter ="LOG_MCAP" 			then n=12;
		if parameter="LOG_S_VOL" 			then n=13;
		if parameter ="CALL_IND" 			then n=14;
		if parameter = "LOG_DAYS_EXP" 		then n=15;
		if parameter = "TICK_CHANGE_IND" 	then n=16;
		if parameter ="BUY_IND" 			then n=17;
		if parameter="Rsq" 					then n=18;
		if parameter ="NObs" 				then n=19; 

run;


proc sql;
	create table Regression_3
	as select a.*, b.Probt
	from Regression_3 A left join ParameterEstimates_p_clus B
	ON A.parameter = b.parameter;
quit;






PROC SORT DATA=REG_DATA; BY SYMBOL_ONLY;RUN;
ODS OUTPUT ParameterEstimates = ParameterEstimates_clus (keep=parameter StdErr probt);
proc surveyreg data=REG_DATA_D2;
cluster SYMBOL_ONLY CHARDATE ;
 
model 
	AUCTION_IND=

	PFOF_IND
	QUOTEDSPREAD_D
	DMMP_IND



/NOINT
;

quit;
ODS HTML;





data ParameterEstimates_s_clus(keep=parameter value Type);
	set ParameterEstimates_clus;
		Type ="S";
		rename StdErr = Value;
		IF find(parameter, "SYMBOL_ONLY")=0;
		IF find(parameter, "CHARDATE")=0;
		parameter = UPCASE(parameter);


run;

data ParameterEstimates_p_clus(keep=parameter probt);
	set ParameterEstimates_clus;
	    IF find(parameter, "SYMBOL_ONLY")=0;
		IF find(parameter, "CHARDATE")=0;
		parameter = UPCASE(parameter);

run;


ODS OUTPUT ParameterEstimates = ParameterEstimates;
ODS OUTPUT FitStatistics = FitStatistics;
ODS OUTPUT NObs = NObs;
proc glm namelen=64  data=REG_DATA;
CLASS CHARDATE;
ABSORB SYMBOL_ONLY;
model 

	AUCTION_IND=

	PFOF_IND
	QUOTEDSPREAD_D
	DMMP_IND

	CHARDATE 

/solution noint; 
run;
quit;




data FitStatistics (keep=parameter value Type);
	set FitStatistics;
	
		rename  RSquare=value;
		parameter = "Rsq";
		type ="E";
	    IF find(parameter, "SYMBOL_ONLY")=0;
		IF find(parameter, "CHARDATE")=0;

run;





data ParameterEstimates_e (keep=parameter value Type);
	set ParameterEstimates;

		rename Estimate=value;
		Type="E";
		IF find(parameter, "SYMBOL_ONLY")=0;
		IF find(parameter, "CHARDATE")=0;
		parameter = UPCASE(parameter);

run;





data nobs(keep=value type parameter);
	set nobs;

		type = "E";
		if label1 = "Number of Observations Read";
		parameter = "NObs";
		rename NObsRead = value;

run;



data Regression_2;
	set ParameterEstimates_e parameterEstimates_s_clus FITSTATISTICS nobs;

		
		if parameter="PFOF_IND" 			then n=2;
		if parameter="ARBITRAGE" 			then n=2.1;
		if parameter="QUOTEDSPREAD_D" 		then n=2.2;
		if parameter="DMMP_IND" 			then n=4;
		if parameter ="ABS_DELTA" 			then n=5;	
		if parameter="GAMMA" 				then n=6;
		if parameter ="VEGA" 				then n=7;
		if parameter="UNDERLYING_VOL" 		then n=8;
		if parameter = "STOCK_QS" 			then n=9;
		if parameter ="INV_OPTION_MIDPOINT" then n=10;
		if parameter ="INV_STOCK_MIDPOINT" 	then n=11;
		if parameter ="LOG_MCAP" 			then n=12;
		if parameter="LOG_S_VOL" 			then n=13;
		if parameter ="CALL_IND" 			then n=14;
		if parameter = "LOG_DAYS_EXP" 		then n=15;
		if parameter = "TICK_CHANGE_IND" 	then n=16;
		if parameter ="BUY_IND" 			then n=17;
		if parameter="Rsq" 					then n=18;
		if parameter ="NObs" 				then n=19; 


run;


proc sql;
	create table Regression_2
	as select a.*, b.Probt
	from Regression_2 A left join ParameterEstimates_p_clus B
	ON A.parameter = b.parameter;
quit;













PROC SORT DATA=REG_DATA; BY SYMBOL_ONLY;RUN;
ODS OUTPUT ParameterEstimates = ParameterEstimates_clus (keep=parameter StdErr probt);
proc surveyreg data=REG_DATA_D2;
cluster SYMBOL_ONLY CHARDATE ;
 
model 
	AUCTION_IND=

	PFOF_IND
	ARBITRAGE
	DMMP_IND

/NOINT
;


quit;
ODS HTML;





data ParameterEstimates_s_clus(keep=parameter value Type);
	set ParameterEstimates_clus;
	Type ="S";

		rename StdErr = Value;
		IF find(parameter, "SYMBOL_ONLY")=0;
		IF find(parameter, "CHARDATE")=0;
		parameter = UPCASE(parameter);


run;

data ParameterEstimates_p_clus(keep=parameter probt);
	set ParameterEstimates_clus;
    IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	  parameter = UPCASE(parameter);

run;


ODS OUTPUT ParameterEstimates = ParameterEstimates;
ODS OUTPUT FitStatistics = FitStatistics;
ODS OUTPUT NObs = NObs;
proc glm namelen=64  data=REG_DATA;
CLASS CHARDATE;
ABSORB SYMBOL_ONLY;
model 

	AUCTION_IND=

	PFOF_IND
	ARBITRAGE
	DMMP_IND


	CHARDATE 

/solution noint; 
run;
quit;




data FitStatistics (keep=parameter value Type);
	set FitStatistics;
	
	rename  RSquare=value;
	parameter = "Rsq";
	type ="E";
    IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	
run;





data ParameterEstimates_e (keep=parameter value Type);
	set ParameterEstimates;
	rename Estimate=value;
	Type="E";
	IF find(parameter, "SYMBOL_ONLY")=0;
	IF find(parameter, "CHARDATE")=0;
	 IF find(parameter, "sender")=0;
	  IF find(parameter, "SENDER")=0;
	  IF find(parameter,"PFOF_Model")=0;
	  IF find(parameter,"DIRECTED_OF")=0;
	 parameter = UPCASE(parameter);

run;





data nobs(keep=value type parameter);
	set nobs;
	type = "E";
	if label1 = "Number of Observations Read";
	parameter = "NObs";
	rename NObsRead = value;

run;



data Regression_1;
	set ParameterEstimates_e parameterEstimates_s_clus FITSTATISTICS nobs;

			
		if parameter="PFOF_IND" 			then n=2;
		if parameter="ARBITRAGE" 			then n=2.1;
		if parameter="QUOTEDSPREAD_D" 		then n=2.2;
		if parameter="DMMP_IND" 			then n=4;
		if parameter ="ABS_DELTA" 			then n=5;	
		if parameter="GAMMA" 				then n=6;
		if parameter ="VEGA" 				then n=7;
		if parameter="UNDERLYING_VOL" 		then n=8;
		if parameter = "STOCK_QS" 			then n=9;
		if parameter ="INV_OPTION_MIDPOINT" then n=10;
		if parameter ="INV_STOCK_MIDPOINT" 	then n=11;
		if parameter ="LOG_MCAP" 			then n=12;
		if parameter="LOG_S_VOL" 			then n=13;
		if parameter ="CALL_IND" 			then n=14;
		if parameter = "LOG_DAYS_EXP" 		then n=15;
		if parameter = "TICK_CHANGE_IND" 	then n=16;
		if parameter ="BUY_IND" 			then n=17;
		if parameter="Rsq" 					then n=18;
		if parameter ="NObs" 				then n=19; 



run;


proc sql;
	create table Regression_1
	as select a.*, b.Probt
	from Regression_1 A left join ParameterEstimates_p_clus B
	ON A.parameter = b.parameter;
quit;








PROC SQL;
	CREATE TABLE Regression_Combined
	AS SELECT 


	A.VALUE AS VALUE_3,	A.PROBT AS PROBT_3, 	A.N as N_3, 	A.PARAMETER AS PARAMETER_3,	A.TYPE AS TYPE_3,
	B.VALUE AS VALUE_2,	B.PROBT AS PROBT_2, 	B.N as N_2, 	B.PARAMETER AS PARAMETER_2,	B.TYPE AS TYPE_2,
	C.VALUE AS VALUE_1,	C.PROBT AS PROBT_1, 	C.N as N_1, 	C.PARAMETER AS PARAMETER_1,	C.TYPE AS TYPE_1

	FROM REGRESSION_3 A 
	LEFT JOIN REGRESSION_2 B
	ON A.PARAMETER=B.PARAMETER & A.TYPE=B.TYPE
	LEFT JOIN REGRESSION_1 C
	ON A.PARAMETER=C.PARAMETER & A.TYPE=C.TYPE
;
QUIT;



data Regression_Combined;
SET Regression_Combined;



IF PARAMETER_3 = "PFOF_IND" & TYPE_3="E" then VARIABLE = PUT("PFOF",$48.);
IF PARAMETER_3 = "PFOF_IND" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="AUCTION_IND" & TYPE_3="E" then VARIABLE = PUT("Auction",$48.);
if PARAMETER_3="AUCTION_IND" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="ARBITRAGE" & TYPE_3="E" then VARIABLE = PUT("Arbitrage$_{t-1}",$48.);
if PARAMETER_3="ARBITRAGE" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="QUOTEDSPREAD_D" & TYPE_3="E" then VARIABLE = PUT("Option Quoted Spread",$48.);
if PARAMETER_3="QUOTEDSPREAD_D" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);



if PARAMETER_3="AUC_PFOF" & TYPE_3="E" then VARIABLE = PUT("Auction $\times$ PFOF",$48.);
if PARAMETER_3="AUC_PFOF" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="DMMP_IND" & TYPE_3="E" then VARIABLE = PUT("DMMP",$48.);
if PARAMETER_3="DMMP_IND" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="VEGA" & TYPE_3="E" then VARIABLE = PUT("Vega",$48.);
if PARAMETER_3="VEGA" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);



IF PARAMETER_3="ABS_DELTA"  & TYPE_3="E" THEN VARIABLE = PUT("$\vert$Delta$\vert$",$48.);
IF PARAMETER_3 ="ABS_DELTA" & TYPE_3="S" THEN VARIABLE = PUT(" ",$48.);

if PARAMETER_3="GAMMA" & TYPE_3="E" then VARIABLE = PUT("Gamma",$48.);
if PARAMETER_3="GAMMA" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

if PARAMETER_3="AUC_PFOF" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);
if PARAMETER_3="AUC_PFOF" & TYPE_3="S" then VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "TICK_CHANGE_IND" & TYPE_3="E" THEN  VARIABLE = PUT("Tick Size",$48.);
IF PARAMETER_3 = "PTICK_CHANGE_IND" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "INV_OPTION_MIDPOINT" & TYPE_3="E" THEN VARIABLE = PUT("1/Option Midpoint",$48.);
IF PARAMETER_3 = "INV_OPTION_MIDPOINT" & TYPE_3="S" THEN VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "INV_STOCK_MIDPOINT" & TYPE_3="E" THEN VARIABLE = PUT("1/Underlying Midpoint",$48.);
IF PARAMETER_3 = "INV_STOCK_MIDPOINT" & TYPE_3="S" THEN VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "CALL_IND" & TYPE_3="E" THEN  VARIABLE = PUT("Call",$48.);
IF PARAMETER_3 = "CALL_IND" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);


IF PARAMETER_3 = "STOCK_QS" & TYPE_3="E" THEN VARIABLE = PUT("Underlying Quoted Spr.",$48.);
IF PARAMETER_3 = "STOCK_QS" & TYPE_3="S" THEN VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "LOG_S_VOL" & TYPE_3="E" THEN  VARIABLE = PUT("Trade size",$48.);
IF PARAMETER_3 = "LOG_S_VOL" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);


IF PARAMETER_3 = "BUY_IND" & TYPE_3="E" THEN  VARIABLE = PUT("Buy",$48.);
IF PARAMETER_3 = "BUY_IND" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);


IF PARAMETER_3 = "ARBITRAGE" & TYPE_3="E" THEN VARIABLE = PUT("Arbitrage$_{t-1}$",$48.);
IF PARAMETER_3 = "ARBITRAGE" & TYPE_3="S" THEN VARIABLE = PUT(" ",$48.);


IF PARAMETER_3 = "LOG_DAYS_EXP" & TYPE_3="E" THEN  VARIABLE = PUT("Days-to-Expiry",$48.);
IF PARAMETER_3 = "LOG_DAYS_EXP" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);


IF PARAMETER_3 ="UNDERLYING_VOL"  & Type_3="E"  then  VARIABLE = PUT("Underlying Volatility$_{t-1}$",$48.);
IF PARAMETER_3 ="UNDERLYING_VOL"  & Type_3="S" then VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "LOG_MCAP" & TYPE_3="E" THEN  VARIABLE = PUT("Underlying MCAP",$48.);
IF PARAMETER_3 = "LOG_MCAP" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);

IF PARAMETER_3 = "LOG_SIZE_VOL" & TYPE_3="E" THEN  VARIABLE = PUT("Trade size",$48.);
IF PARAMETER_3 = "LOG_SIZE_VOL" & TYPE_3="S" THEN  VARIABLE = PUT(" ",$48.);



IF PARAMETER_3 = "Rsq" & TYPE_3="E" THEN  VARIABLE = PUT("Rsq",$48.);

IF PARAMETER_3 = "NObs"  THEN  VARIABLE = PUT("NObs",$48.);

char_2dash= put("\\",$12.);


	
	if VARIABLE not in ("Rsq","NObs") then do;
	
			if    PROBT_1<0.01 & Type_1="E" then VALUE_CHAR_1=PUT(CATS(PUT(Value_1,8.3),"\threeS"),$48.);
			else if PROBT_1<0.05 & Type_1="E" then VALUE_CHAR_1=PUT(CATS(PUT(Value_1,8.3),"\twoS"),$48.);
			else if PROBT_1<0.1 & Type_1="E" then VALUE_CHAR_1=PUT(CATS(PUT(Value_1,8.3),"\oneS"),$48.);
			else if PROBT_1>0.1 & Type_1="E" then VALUE_CHAR_1=PUT(PUT(Value_1,8.3),$CHAR48.);
	end;

	if VARIABLE not in ("Rsq","NObs") & NOT MISSING(Value_2) then do;
	
			if    PROBT_2<0.01 & Type_2="E" then VALUE_CHAR_2=PUT(CATS(PUT(Value_2,8.3),"\threeS"),$28.);
			else if PROBT_2<0.05 & Type_2="E" then VALUE_CHAR_2=PUT(CATS(PUT(Value_2,8.3),"\twoS"),$28.);
			else if PROBT_2<0.1 & Type_2="E" then VALUE_CHAR_2=PUT(CATS(PUT(Value_2,8.3),"\oneS"),$28.);
			else if PROBT_2>0.1 & Type_2="E" then VALUE_CHAR_2=PUT(PUT(Value_2,8.3),$CHAR48.);
	end;
	
	
	
	if VARIABLE not in ("Rsq","NObs") & NOT MISSING(Value_3) then do;
	
			if    PROBT_3<0.01 & Type_3="E" then VALUE_CHAR_3=PUT(CATS(PUT(Value_3,8.3),"\threeS"),$48.);
			else if PROBT_3<0.05 & Type_3="E" then VALUE_CHAR_3=PUT(CATS(PUT(Value_3,8.3),"\twoS"),$48.);
			else if PROBT_3<0.1 & Type_3="E" then VALUE_CHAR_3=PUT(CATS(PUT(Value_3,8.3),"\oneS"),$48.);
			else if PROBT_3>0.1 & Type_3="E" then VALUE_CHAR_3=PUT(PUT(Value_3,8.3),$CHAR48.);
	end;

	
	
	


		if Type_3="S" then do;
				VARIABLE = PUT(" ",$48.);
			/*PUT STANDARD ERRORS IN BRACKETS*/
				IF NOT MISSING(Value_1) THEN
				VALUE_CHAR_1=PUT(CATS("(",PUT(Value_1,8.3),")"),$28.);
				IF NOT MISSING(Value_2) THEN
				VALUE_CHAR_2=PUT(CATS("(",PUT(Value_2,8.3),")"),$28.);
				IF NOT MISSING(Value_3) THEN
				VALUE_CHAR_3=PUT(CATS("(",PUT(Value_3,8.3),")"),$28.);
				
			end;
			
	
	 


if VARIABLE in ("Rsq","NObs") then do;
	

	VALUE_CHAR_1=PUT(PUT(Value_1,8.3),$28.);
	VALUE_CHAR_2=PUT(PUT(Value_2,8.3),$28.);
	VALUE_CHAR_3=PUT(PUT(Value_3,8.3),$28.);
	
END;

RUN;


proc sort data=Regression_Combined;by n_3 TYPE_3;run;



/*=========================================*/
ODS GRAPHICS OFF;
ODS RESULTS;
ODS SELECT ALL;
ODS TITLE "TABLE 8: Auction LPM  (Pseudo Data)";
FOOTNOTE "This table presents results from a linear probability model for auctions using pseudo OPRA
data.";
PROC REPORT data=Regression_Combined;
columns
		variable 
		value_char_1
		value_char_2
		value_char_3;

DEFINE VARIABLE / DISPLAY "Variable" format =$168.;
DEFINE value_char_1 / DISPLAY "REG1" format =$168.;
DEFINE value_char_2 / DISPLAY "REG2" format =$168.;
DEFINE value_char_3 / DISPLAY "REG3" format =$168.;

run;


/*=========================================*/
FOOTNOTE " ";
ODS TITLE " ";







proc printto log=log;
run;





